﻿var TMMobilePage = function(pageContainer) {
    TMMobilePage.superclass.constructor.call(this, pageContainer);

    var self = this;

    this.ModuleCode = "";

    this.setModuleAction = function() {

    };

    this.initialize = override(self.initialize, function() {
        pageContainer.bind('onBeforePageShow', function() {
            if (app && app.TMMService)
                app.TMMService.setModuleCode(self.ModuleCode);

            self.setModuleAction();
        });

        $(document).keydown(function(e) {
            if (!app.Phone.getMobilePlatformIndex()) {
                if (!app.CurrentPage || !app.CurrentPage.instance || app.CurrentPage.instance != self || app.CurrentPage.instance == app.Pages.Authentication.instance)
                    return true;

                if (e.keyCode == Keys.M) {
                    app.showLeftMenu();
                    return false;
                } else if (e.keyCode == Keys.A) {
                    if (app.CurrentPage && app.CurrentPage.instance) {
                        app.CurrentPage.instance.showActions();
                        return false;
                    }
                } else if (e.keyCode == Keys.R && app.CurrentPage.instance.getPullDownData) {
                    app.CurrentPage.instance.getPullDownData();
                    return false;
                } else if (e.keyCode == Keys.N) {
                    if (!app.Pages.Notifications.instance) {
                        app.Pages.Notifications.instance = new NotificationsPage(app.Pages.Notifications.container);
                        app.Pages.Notifications.instance.refresh();
                    }
                    app.changePage(app.Pages.Notifications, false, true);
                    return false;
                }
            }
        });

        $(document).bind('menu_opened', function() {
            self.hideActions();
        });
    });
};
extend(TMMobilePage, MobilePage);